package com.wangcw.minicat.bean;

import java.util.concurrent.*;

/**
 * 线程配置
 */
public class ThreadConfigBean {

    //线程池中核心线程数的最大值
    private int corePoolSize = 10;
    //线程池中能拥有最多线程数
    private int maximumPoolSize =50;
    //空闲线程的存活时间
    private long keepAliveTime = 100L;
    //空闲线程的存活时间的单位
    private TimeUnit unit = TimeUnit.SECONDS;

    private BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(50);

    private ThreadFactory threadFactory = Executors.defaultThreadFactory();

    private RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy();


    public int getCorePoolSize() {
        return corePoolSize;
    }

    public void setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    public int getMaximumPoolSize() {
        return maximumPoolSize;
    }

    public void setMaximumPoolSize(int maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }

    public long getKeepAliveTime() {
        return keepAliveTime;
    }

    public void setKeepAliveTime(long keepAliveTime) {
        this.keepAliveTime = keepAliveTime;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    public void setUnit(TimeUnit unit) {
        this.unit = unit;
    }

    public BlockingQueue<Runnable> getWorkQueue() {
        return workQueue;
    }

    public void setWorkQueue(BlockingQueue<Runnable> workQueue) {
        this.workQueue = workQueue;
    }

    public ThreadFactory getThreadFactory() {
        return threadFactory;
    }

    public void setThreadFactory(ThreadFactory threadFactory) {
        this.threadFactory = threadFactory;
    }

    public RejectedExecutionHandler getHandler() {
        return handler;
    }

    public void setHandler(RejectedExecutionHandler handler) {
        this.handler = handler;
    }
}
